#delimit;
set more off;

set logtype text;
log using /home/dnc2101/Accidental_Deaths/Vital_Stats/do_files_other_years/make_state_fips_03_04.txt, replace;


** The 2003 and 2004 Vital Stats data have different coding of state of occurrence of death and state of residence of decedent than other years;
** Previous years have numerical state FIPS code in a variables called fipssto and fipsstr;
** 2003 and 2004 have alphabetical state abbreviation (AL, AK, AZ, AR, CA, that stuff) in variables called stateoc and staters , ;
** so for these years I need to change that info into a numerical coding in variables called fipssto and fipsstr;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/dta_files_other_years/mort2003.dta", clear;

gen fipssto=.;
replace fipssto=2 if stateoc=="AK";
replace fipssto=1 if stateoc=="AL";
replace fipssto=5 if stateoc=="AR";
replace fipssto=4 if stateoc=="AZ";
replace fipssto=6 if stateoc=="CA";
replace fipssto=8 if stateoc=="CO";
replace fipssto=9 if stateoc=="CT";
replace fipssto=11 if stateoc=="DC";
replace fipssto=10 if stateoc=="DE";
replace fipssto=12 if stateoc=="FL";
replace fipssto=13 if stateoc=="GA";
replace fipssto=15 if stateoc=="HI";
replace fipssto=19 if stateoc=="IA";
replace fipssto=16 if stateoc=="ID";
replace fipssto=17 if stateoc=="IL";
replace fipssto=18 if stateoc=="IN";
replace fipssto=20 if stateoc=="KS";
replace fipssto=21 if stateoc=="KY";
replace fipssto=22 if stateoc=="LA";
replace fipssto=25 if stateoc=="MA";
replace fipssto=24 if stateoc=="MD";
replace fipssto=23 if stateoc=="ME";
replace fipssto=26 if stateoc=="MI";
replace fipssto=27 if stateoc=="MN";
replace fipssto=29 if stateoc=="MO";
replace fipssto=28 if stateoc=="MS";
replace fipssto=30 if stateoc=="MT";
replace fipssto=37 if stateoc=="NC";
replace fipssto=38 if stateoc=="ND";
replace fipssto=31 if stateoc=="NE";
replace fipssto=33 if stateoc=="NH";
replace fipssto=34 if stateoc=="NJ";
replace fipssto=35 if stateoc=="NM";
replace fipssto=32 if stateoc=="NV";
replace fipssto=36 if stateoc=="NY";
replace fipssto=39 if stateoc=="OH";
replace fipssto=40 if stateoc=="OK";
replace fipssto=41 if stateoc=="OR";
replace fipssto=42 if stateoc=="PA";
replace fipssto=44 if stateoc=="RI";
replace fipssto=45 if stateoc=="SC";
replace fipssto=46 if stateoc=="SD";
replace fipssto=47 if stateoc=="TN";
replace fipssto=48 if stateoc=="TX";
replace fipssto=49 if stateoc=="UT";
replace fipssto=51 if stateoc=="VA";
replace fipssto=50 if stateoc=="VT";
replace fipssto=53 if stateoc=="WA";
replace fipssto=55 if stateoc=="WI";
replace fipssto=54 if stateoc=="WV";
replace fipssto=56 if stateoc=="WY";
drop if fipssto==.;



gen fipsstr=.;
replace fipsstr=2 if staters=="AK";
replace fipsstr=1 if staters=="AL";
replace fipsstr=5 if staters=="AR";
replace fipsstr=4 if staters=="AZ";
replace fipsstr=6 if staters=="CA";
replace fipsstr=8 if staters=="CO";
replace fipsstr=9 if staters=="CT";
replace fipsstr=11 if staters=="DC";
replace fipsstr=10 if staters=="DE";
replace fipsstr=12 if staters=="FL";
replace fipsstr=13 if staters=="GA";
replace fipsstr=15 if staters=="HI";
replace fipsstr=19 if staters=="IA";
replace fipsstr=16 if staters=="ID";
replace fipsstr=17 if staters=="IL";
replace fipsstr=18 if staters=="IN";
replace fipsstr=20 if staters=="KS";
replace fipsstr=21 if staters=="KY";
replace fipsstr=22 if staters=="LA";
replace fipsstr=25 if staters=="MA";
replace fipsstr=24 if staters=="MD";
replace fipsstr=23 if staters=="ME";
replace fipsstr=26 if staters=="MI";
replace fipsstr=27 if staters=="MN";
replace fipsstr=29 if staters=="MO";
replace fipsstr=28 if staters=="MS";
replace fipsstr=30 if staters=="MT";
replace fipsstr=37 if staters=="NC";
replace fipsstr=38 if staters=="ND";
replace fipsstr=31 if staters=="NE";
replace fipsstr=33 if staters=="NH";
replace fipsstr=34 if staters=="NJ";
replace fipsstr=35 if staters=="NM";
replace fipsstr=32 if staters=="NV";
replace fipsstr=36 if staters=="NY";
replace fipsstr=39 if staters=="OH";
replace fipsstr=40 if staters=="OK";
replace fipsstr=41 if staters=="OR";
replace fipsstr=42 if staters=="PA";
replace fipsstr=44 if staters=="RI";
replace fipsstr=45 if staters=="SC";
replace fipsstr=46 if staters=="SD";
replace fipsstr=47 if staters=="TN";
replace fipsstr=48 if staters=="TX";
replace fipsstr=49 if staters=="UT";
replace fipsstr=51 if staters=="VA";
replace fipsstr=50 if staters=="VT";
replace fipsstr=53 if staters=="WA";
replace fipsstr=55 if staters=="WI";
replace fipsstr=54 if staters=="WV";
replace fipsstr=56 if staters=="WY";
drop if fipsstr==.;







save "/home/dnc2101/Accidental_Deaths/Vital_Stats/dta_files_other_years/mort2003.dta", replace;






use "/home/dnc2101/Accidental_Deaths/Vital_Stats/dta_files_other_years/mort2004.dta", clear;


gen fipssto=.;
replace fipssto=2 if stateoc=="AK";
replace fipssto=1 if stateoc=="AL";
replace fipssto=5 if stateoc=="AR";
replace fipssto=4 if stateoc=="AZ";
replace fipssto=6 if stateoc=="CA";
replace fipssto=8 if stateoc=="CO";
replace fipssto=9 if stateoc=="CT";
replace fipssto=11 if stateoc=="DC";
replace fipssto=10 if stateoc=="DE";
replace fipssto=12 if stateoc=="FL";
replace fipssto=13 if stateoc=="GA";
replace fipssto=15 if stateoc=="HI";
replace fipssto=19 if stateoc=="IA";
replace fipssto=16 if stateoc=="ID";
replace fipssto=17 if stateoc=="IL";
replace fipssto=18 if stateoc=="IN";
replace fipssto=20 if stateoc=="KS";
replace fipssto=21 if stateoc=="KY";
replace fipssto=22 if stateoc=="LA";
replace fipssto=25 if stateoc=="MA";
replace fipssto=24 if stateoc=="MD";
replace fipssto=23 if stateoc=="ME";
replace fipssto=26 if stateoc=="MI";
replace fipssto=27 if stateoc=="MN";
replace fipssto=29 if stateoc=="MO";
replace fipssto=28 if stateoc=="MS";
replace fipssto=30 if stateoc=="MT";
replace fipssto=37 if stateoc=="NC";
replace fipssto=38 if stateoc=="ND";
replace fipssto=31 if stateoc=="NE";
replace fipssto=33 if stateoc=="NH";
replace fipssto=34 if stateoc=="NJ";
replace fipssto=35 if stateoc=="NM";
replace fipssto=32 if stateoc=="NV";
replace fipssto=36 if stateoc=="NY";
replace fipssto=39 if stateoc=="OH";
replace fipssto=40 if stateoc=="OK";
replace fipssto=41 if stateoc=="OR";
replace fipssto=42 if stateoc=="PA";
replace fipssto=44 if stateoc=="RI";
replace fipssto=45 if stateoc=="SC";
replace fipssto=46 if stateoc=="SD";
replace fipssto=47 if stateoc=="TN";
replace fipssto=48 if stateoc=="TX";
replace fipssto=49 if stateoc=="UT";
replace fipssto=51 if stateoc=="VA";
replace fipssto=50 if stateoc=="VT";
replace fipssto=53 if stateoc=="WA";
replace fipssto=55 if stateoc=="WI";
replace fipssto=54 if stateoc=="WV";
replace fipssto=56 if stateoc=="WY";
drop if fipssto==.;




gen fipsstr=.;
replace fipsstr=2 if staters=="AK";
replace fipsstr=1 if staters=="AL";
replace fipsstr=5 if staters=="AR";
replace fipsstr=4 if staters=="AZ";
replace fipsstr=6 if staters=="CA";
replace fipsstr=8 if staters=="CO";
replace fipsstr=9 if staters=="CT";
replace fipsstr=11 if staters=="DC";
replace fipsstr=10 if staters=="DE";
replace fipsstr=12 if staters=="FL";
replace fipsstr=13 if staters=="GA";
replace fipsstr=15 if staters=="HI";
replace fipsstr=19 if staters=="IA";
replace fipsstr=16 if staters=="ID";
replace fipsstr=17 if staters=="IL";
replace fipsstr=18 if staters=="IN";
replace fipsstr=20 if staters=="KS";
replace fipsstr=21 if staters=="KY";
replace fipsstr=22 if staters=="LA";
replace fipsstr=25 if staters=="MA";
replace fipsstr=24 if staters=="MD";
replace fipsstr=23 if staters=="ME";
replace fipsstr=26 if staters=="MI";
replace fipsstr=27 if staters=="MN";
replace fipsstr=29 if staters=="MO";
replace fipsstr=28 if staters=="MS";
replace fipsstr=30 if staters=="MT";
replace fipsstr=37 if staters=="NC";
replace fipsstr=38 if staters=="ND";
replace fipsstr=31 if staters=="NE";
replace fipsstr=33 if staters=="NH";
replace fipsstr=34 if staters=="NJ";
replace fipsstr=35 if staters=="NM";
replace fipsstr=32 if staters=="NV";
replace fipsstr=36 if staters=="NY";
replace fipsstr=39 if staters=="OH";
replace fipsstr=40 if staters=="OK";
replace fipsstr=41 if staters=="OR";
replace fipsstr=42 if staters=="PA";
replace fipsstr=44 if staters=="RI";
replace fipsstr=45 if staters=="SC";
replace fipsstr=46 if staters=="SD";
replace fipsstr=47 if staters=="TN";
replace fipsstr=48 if staters=="TX";
replace fipsstr=49 if staters=="UT";
replace fipsstr=51 if staters=="VA";
replace fipsstr=50 if staters=="VT";
replace fipsstr=53 if staters=="WA";
replace fipsstr=55 if staters=="WI";
replace fipsstr=54 if staters=="WV";
replace fipsstr=56 if staters=="WY";
drop if fipsstr==.;





save "/home/dnc2101/Accidental_Deaths/Vital_Stats/dta_files_other_years/mort2004.dta", replace;



log off;


